package com.cloud.feign.configure;

import com.cloud.feign.bean.User;
import com.cloud.feign.service.FeignClient1;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.Collections;
import java.util.List;

/**
 * @author: zoub
 * @date 2021/2/6 15:28
 **/
@Component
public class FeignClientFallbackFactory implements FallbackFactory<FeignClient1> {

    @Override
    public FeignClient1 create(Throwable cause) {

        return new FeignClient1() {
            @Override
            public String sayHiFromClientOne(String name) {
                return "发生错误！reason：" + cause.getMessage();
            }

            @Override
            public User getUser(User user) {
                return new User(0, "user error");
            }

            @Override
            public List<User> getList() {
                return Collections.emptyList();
            }
        };
    }
}
